home *** CD-ROM | disk | FTP | other *** search
/ Libris Britannia 4 / science library(b).zip / science library(b) / PROGRAMM / DB_CLIPP / 0769A.ZIP / ZOOMBOX.ASM < prev    next >
Assembly Source File  |  1987-05-29  |  19KB  |  397 lines

  1. ;-----------------------------------------------------------------------------------------------------------------------
  2. ; Filename: EXTASM19.ASM
  3. ; Program.: Clipper Extended Library 19
  4. ; Author..: Gustavo J Grubba.
  5. ; Date....: May, 1987
  6. ; Notes...: User-defined functions in 8088 assembly for Clipper.
  7. ;
  8. ; ZoomBox ::= Explode Box for Messages
  9.  
  10.   Name                 Extasm19
  11.   Public               ZoomBox
  12.   Extrn                _ParNI:Far                                ; Get Integer Parameter
  13.  
  14.   DGROUP GROUP         datasg                                    ; Clipper's Data Segment
  15.   datasg segment       public 'DATA'
  16.  
  17.   Video_Segment        dw         0B800h
  18.   Video_Page           db         0
  19.   Video_Mode           db         ?
  20.   Enable_Values        db         2Ch,28h,2Dh,29h,2Ah,2Eh,1Eh    ; Values to enable CGA display
  21.  
  22.   Window_Row           db         ?
  23.   Window_Column        db         ?
  24.   Window_Width         db         ?
  25.   Window_Height        db         ?
  26.  
  27.   Win_Row              db         ?
  28.   Win_Column           db         ?
  29.   Win_Width            db         ?
  30.   Win_Height           db         ?
  31.   Win_Attr             db         ?
  32.  
  33.   Zoom_Time            dw         ?
  34.  
  35.   Frequency            db         0FFh
  36.   datasg               ends
  37.  
  38.   _Prog                Segment
  39.                        Assume     CS:_Prog,DS:DGROUP,ES:DGROUP
  40.  
  41. ;-----------------------------------------------------------------------------------------------------------------------
  42. ; ZoomBox
  43. ; Syntax: do ZoomBox with <ExpnA>,<ExpnB>,<ExpnC>,<ExpnD>,<ExpnE>
  44. ; Return: Nothing
  45. ;
  46. ; On Entry: ExpnA Upper Left Corner (Row)       (0..24)
  47. ;           ExpnB Upper Left Corner (Column)    (0..79)
  48. ;           ExpnC Width of finished Box         (6..80)
  49. ;           ExpnD Heigth of finished Box        (4..24)
  50. ;           ExpnE Attribute
  51. ;
  52. ;           Attribute is in binary format as expected by 6845
  53. ;
  54. ;                  7 6 5 4 3 2 1 0
  55. ;
  56. ;                  B R G B I R G B
  57. ;                     
  58. ;                            Foreground Color
  59. ;                         Intensity
  60. ;                      Background Color
  61. ;                   Blinking
  62. ;
  63. ;    Usage: Example of a .PRG file using ZoomBox
  64. ;
  65. ;           * ZoomTest.PRG
  66. ;
  67. ;             External ZoomBox
  68. ;             Clear
  69. ;             Do ZoomBox with 05,04,72,08,79    && Box of 72 by 8 starting at 5,4 using white over red
  70. ;             Set Color to W+/R                 && Set text attribute to white over red
  71. ;             @  09,32 say "Testing Zoom Box"
  72. ;             Inkey(30)                         && Wait a while (or strike any key to go on)
  73. ;             Set Color to
  74. ;             Clear
  75. ;             Quit
  76. ;
  77. ;
  78. ;    Compile: C:>Clipper ZoomTest -m <Enter>
  79. ;    Link...: C:>Plink86    <Enter>
  80. ;
  81. ;             PLINK86plus ( Nantucket ) Version 2.21.
  82. ;             Copyright (C) 1984, 1985, 1986 by Phoenix Technologies Ltd.,
  83. ;             All Rights Reserved.
  84. ;
  85. ;             =>fi ZoomTest <Enter>
  86. ;             =>fi Extasm19 <Enter>
  87. ;             =>Lib Clipper <Enter>
  88. ;             =>;           <Enter>
  89. ;
  90.  
  91.  
  92. ;------------------- Save Current Registers Values
  93.  
  94.   ZoomBox              Proc       Far
  95.                        Push       BP                             ; Save stack
  96.                        Mov        BP,SP
  97.                        Push       DS
  98.                        Push       ES
  99.                        Push       SS
  100.                        Push       DX
  101.  
  102.   ;------------------- Check the current video mode to see if it's one of the 80-column text modes (2, 3, or 7).
  103.   ;                    If it is, then continue.  If it's not, abort this routine.
  104.  
  105.                        Mov        AH,15                          ; Get video page and display mode
  106.                        Int        10h
  107.                        Cmp        AL,2                           ; Video mode 2 ?
  108.                        Je         Par0                           ; Yes, then continue
  109.                        Cmp        AL,3                           ; Mode 3?
  110.                        Je         Par0                           ; Yes, then continue
  111.                        Mov        Video_Segment,0B000h           ; Set VIDEO_SEGMENT for monochrome
  112.                        Cmp        AL,7                           ; Mode 7 (monochrome)?
  113.                        Je         Par0                           ; Yes, then continue
  114.                        Jmp        Exit
  115.  
  116.   ;------------------- Get Parameters Sent By Caller
  117.  
  118.   Par0:                Mov        Video_Mode,AL                  ; Save Mode
  119.  
  120.                        Mov        AX,01                          ; First parameter
  121.                        Push       AX
  122.                        Call       _PARNI                         ; Get Upper Left Row
  123.                        Add        SP,2                           ; Fix up stack
  124.  
  125.                        Mov        Window_Row,AL                  ; Save Value
  126.                        Cmp        AL,20                          ; Check for Valid Row
  127.                        Jb         Par1                           ; Continue if OK
  128.                        Jmp        Exit                           ; Leave procedure if not
  129.  
  130.   Par1:                Mov        AX,02                          ; Second param eter 
  131.                        Push       AX
  132.                        Call       _PARNI                         ; Get Upper Left Column
  133.                        Add        SP,2                           ; Fix up stack
  134.  
  135.                        Mov        Window_Column,AL               ; Save Value
  136.                        Cmp        AL,72                          ; Check for Valid Column
  137.                        Jb         Par2                           ; Continue if OK
  138.                        Jmp        Exit                           ; Leave procedure if not
  139.  
  140.   Par2:                Mov        AX,03                          ; Third parameter
  141.                        Push       AX
  142.                        Call       _PARNI                         ; Get Window Width
  143.                        Add        SP,2                           ; Fix up stack
  144.  
  145.                        Mov        Window_Width,AL                ; Save Value
  146.                        Cmp        AL,07                          ; Check for Valid Width
  147.                        Ja         Par3                           ; Continue if OK
  148.                        Jmp        Exit                           ; Leave procedure if not
  149.  
  150.   Par3:                Mov        AX,04                          ; Fourth parameter
  151.                        Push       AX
  152.                        Call       _PARNI                         ; Get Window Height
  153.                        Add        SP,2                           ; Fix up stack
  154.  
  155.                        Mov        Window_Height,AL               ; Save Value
  156.                        Cmp        AL,05                          ; Check for Valid Height
  157.                        Ja         Par4                           ; Continue if OK
  158.                        Jmp        Exit                           ; Leave procedure if not
  159.  
  160.   Par4:                Mov        AX,05                          ; Fifth parameter
  161.                        Push       AX
  162.                        Call       _PARNI                         ; Get Attribute
  163.                        Add        SP,2                           ; Fix up stack
  164.  
  165.                        Mov        Win_Attr,AL                    ; Save Value
  166.  
  167.   ;------------------- Delay Time
  168.  
  169.                        Mov        Zoom_Time,1000h                ; Set zoom delay
  170.  
  171.   ;------------------- Set smallest window possible and find out its coordinates
  172.  
  173.  
  174.                        Mov        AL,Window_Width                ; Get Smallest window UPC
  175.                        Shr        AL,1
  176.                        Add        AL,Window_Column
  177.                        Sub        AL,02
  178.                        Mov        Win_Column,AL
  179.  
  180.                        Mov        AL,Window_Height               ; Get Smallest window UPR
  181.                        Shr        AL,1
  182.                        Add        AL,Window_Row
  183.                        Dec        AL
  184.                        Mov        Win_Row,AL
  185.  
  186.                        Mov        Win_Width,06                   ; Minimum size6x4
  187.                        Mov        Win_Height,04
  188.  
  189.   ;------------------- Zoom it out
  190.  
  191.   Init0:               Cmp        Video_Mode,07                  ; Is it monochrome ?
  192.                        Je         Init1                          ; Yes, then skip next
  193.                        Call       Video_Disable                  ; Disable video
  194.   Init1:               Call       Window                         ; Draw window
  195.                        Cmp        Video_Mode,07                  ; Is it monochrome ?
  196.                        Je         Init2                          ; Yes, then skip next
  197.                        Call       Video_Enable                   ; Enable video
  198.  
  199.   Init2:               Call       Squish                         ; Squish the speaker
  200.                        Sub        Frequency,04                   ; Make frequency lower
  201.  
  202.                        Mov        AL,Window_Column
  203.                        Cmp        AL,Win_Column                  ; Has it gotten to its source ?
  204.                        Je         Init3                          ; Yes, then don't increment width
  205.                        Add        Win_Width,02                   ; No, the incremet its width
  206.                        Dec        Win_Column                     ; Set new Column
  207.  
  208.   Init3:               Mov        AL,Win_Row
  209.                        Cmp        AL,Window_Row                  ; Has it gotten to its source ?
  210.                        Je         Init4                          ; Yes, then don't increment height
  211.                        Add        Win_Height,02                  ; No, the incremet its height
  212.                        Dec        Win_Row                        ; Set new Row
  213.                        Jmp        Init0
  214.  
  215.   Init4:               Nop
  216.                        Mov        AL,Window_Column
  217.                        Cmp        AL,Win_Column
  218.                        Jne        Init0
  219.                        Mov        AL,Win_Row
  220.                        Cmp        AL,Window_Row                  ; Has it gotten to its source ?
  221.                        Jne        Init0
  222.  
  223.   ;------------------- Restore Registers and Return to Caller
  224.  
  225.   Exit:
  226.                        Pop        DX                             ; Restore Stack
  227.                        Pop        SS
  228.                        Pop        ES
  229.                        Pop        DS
  230.                        Pop        BP
  231.  
  232.                        Ret
  233.  
  234.   ZoomBox              Endp
  235.  
  236.   ;---------------------------------------------------------------------------------------------------------------------
  237.   ;------------------- Subroutines
  238.  
  239.  ;----------------------------------------------------------------------------------------------------------------------
  240.  ; VIDEO_OFFSET Calculates the offset address in video memory that corresponds 
  241.  ; to the given row/col, and video page.
  242.  ;
  243.  ; Entry:  DH,DL - Row, Column           | Exit:  DI - offset
  244.  ;         BX    - Video Page            |
  245.  ;----------------------------------------------------------------------------------------------------------------------
  246.  
  247.   Video_Offset         Proc       Near
  248.                        Mov        AL,160                         ; Row * 160
  249.                        Mul        DH                             ; Result in AX
  250.  
  251.                        Shl        DL,1                           ; Column * 2
  252.                        Xor        DH,DH                          ; Byte to wordin DX
  253.                        Add        AX,DX                          ; Add the two
  254.                        Mov        DI,AX                          ; Save result in DI
  255.                        Mov        AX,1000h                       ; Length of one video page
  256.                        Mul        BX                             ; Page * 1000h
  257.  
  258.                        Add        DI,AX                          ; Complete theoffset address
  259.                        Ret
  260.   Video_Offset         Endp
  261.  
  262.   ;---------------------------------------------------------------------------------------------------------------------
  263.   ; Video_Enable and Video_Disable routines disable and enable CGA video by wri
  264.   ; ting to the Mode Select Register
  265.   ; at port address 3D8h.
  266.   ;---------------------------------------------------------------------------------------------------------------------
  267.  
  268.   Video_Disable        Proc       Near
  269.                        Mov        DX,3DAh                        ; Load Status Register address
  270.   Disable1:            In         AL,DX                          ; Get video status
  271.                        Test       AL,8                           ; Vertical retrace active?
  272.                        Je         Disable1                       ; No, then wait until it is
  273.                        Sub        DX,2                           ; Load MSR address
  274.                        Mov        AL,25h                         ; Value to disable video
  275.                        Out        DX,AL                          ; Send it to the adapter
  276.                        Ret
  277.   Video_Disable        Endp
  278.  
  279.   Video_Enable         Proc       Near
  280.                        Mov        AL,Video_Mode                  ; Get current video mode
  281.                        Lea        BX,Enable_Values               ; Offset of enable value table
  282.                        Xlat                                      ; Get the value to enable video
  283.                        Mov        DX,3D8h                        ; Load addressof MSR
  284.                        Out        DX,AL                          ; OUT the enable value
  285.                        Ret 
  286.   Video_Enable         Endp 
  287.  
  288.   ;---------------------------------------------------------------------------------------------------------------
  289.   ; Squish the speaker
  290.   ;---------------------------------------------------------------------------------------------------------------
  291.  
  292.   Squish               Proc       Near
  293.                        Mov        AL,182                         ; Notify 8253 that frequency data is coming
  294.                        Out        67,AL
  295.                        Mov        AL,Frequency                   ; Low byte frequency
  296.                        Out        66,AL
  297.                        Mov        AL,00                          ; High byte frequency
  298.                        Out        66,AL
  299.                        In         AL,97                          ; Activate Speaker
  300.                        Or         AL,03
  301.                        Out        97,AL
  302.                        Mov        CX,Zoom_Time                   ; Time delay for sound duration
  303.   Sq1:                 Loop       Sq1
  304.                        In         AL,97                          ; Deactivate Speaker
  305.                        And        AL,252
  306.                        Out        97,AL
  307.                        Ret
  308.   Squish               Endp
  309.  
  310. ;-----------------------------------------------------------------------------------------------------------------------
  311. ; Window
  312. ; ------
  313. ;
  314. ; Window draws the window border onto the screen.  Character/attribute pairs are
  315.  
  316. ; sent directly to video memory for fast
  317. ; display speed.
  318. ;
  319. ;-----------------------------------------------------------------------------------------------------------------------
  320.  
  321.   Window               Proc       Near
  322.  
  323.                        Mov        DH,Win_Row                     ; Get coordinates of window corner
  324.                        Mov        DL,Win_Column
  325.                        Mov        ES,Video_Segment               ; Point ES to video buffer
  326.                        Cld                                       ; Clear DF forstring operations
  327.                        Mov        BL,Video_Page                  ; Get video page in BX 
  328.                        Xor        BH,BH 
  329.                        Call       Video_Offset                   ; Calculate starting address
  330.  
  331. ;------------------- Write the top line of the window border to video.
  332.  
  333.                        Mov        AL,201                         ; Start with upper left corner
  334.                        Mov        AH,Win_Attr                    ; Set attribute
  335.                        Stosw
  336.                        Mov        CL,Win_Width                   ; Do the next n (Columns) characters
  337.                        Mov        CH,00
  338.                        Mov        AL,205
  339.                        Rep        Stosw
  340.                        Mov        AL,187                         ; Do upper right corner
  341.                        Stosw
  342.  
  343.   ;------------------- Now write the next n (Rows) lines to the display.
  344.  
  345.                        Mov        AL,Win_Width                   ; Set DI for new line
  346.                        Shl        AL,1
  347.                        Sub        AH,AH
  348.                        Add        DI,156
  349.                        Sub        DI,AX
  350.                        Mov        CL,Win_Height                  ; n (Height) lines to do
  351.                        Mov        CH,00
  352.   Window1:             Push       CX                             ; Save line counter
  353.                        Mov        AL,186                         ; Do leftmost column
  354.                        Mov        AH,Win_Attr
  355.                        Stosw
  356.                        Mov        AL,32                          ; Do next N columns (blank)
  357.                        Mov        AH,Win_Attr
  358.                        Mov        CL,Win_Width
  359.                        Mov        CH,00
  360.                        Rep        Stosw
  361.                        Mov        AL,186                         ; Do rightmostcolumn
  362.                        Mov        AH,Win_Attr
  363.                        Stosw
  364.                        Mov        AL,Win_Width                   ; Set DI for new line
  365.                        Shl        AL,1
  366.                        Sub        AH,AH
  367.                        Add        DI,156
  368.                        Sub        DI,AX
  369.                        Pop        CX                             ; Retrieve counter
  370.                        Loop       Window1                        ; Loop until finished
  371.  
  372.   ;------------------- Finish things up by writing the last line.
  373.  
  374.                        Mov        AL,200                         ; lower left corner
  375.                        Mov        AH,Win_Attr                    ; Set attribute
  376.                        Stosw
  377.                        Mov        CL,Win_Width                   ; next 28 characters
  378.                        Mov        CH,00
  379.                        Mov        AL,205
  380.                        Rep        Stosw
  381.                        Mov        AL,188                         ; lower right corner
  382.                        Stosw
  383.  
  384.                        Ret
  385.  
  386.   Window               Endp
  387.  
  388.   ;------------------- End of Subroutines
  389.  
  390.   _Prog                Ends
  391.                        End
  392.  
  393. ; Eof: EXTASM19.ASM -----------------------------------------------------------
  394. -----------------------------------------
  395.  
  396.  
  397.